import type { TableColumn } from '@/framework/components/core/super-table';
import { i18n } from '@/locales';

export type TableListItem = {
  id;
  type;
  originalSerial;
  name;
  projectName;
  serial;
  epc;
  sampleTime;
  sampleAddress;
  capacity;
  preservUserName;
  storageDesp;
  status;
};
export type TableColumnItem = TableColumn<TableListItem>;

// 类型
export const sampleTypeObj = {
  3: '暂存样本',
  4: '保藏样本',
};

export const baseColumns: TableColumnItem[] = [
  {
    type: 'seq',
    title: '序号',
    width: 60,
  },
  {
    // @ts-ignore
    title: `所属${i18n.global.t('specimen.topic')}组`,
    field: 'projectName',
  },
  {
    title: '样本类型',
    field: 'type',
    formatter: ({ cellValue }) => {
      return sampleTypeObj[cellValue];
    },
  },
  {
    // @ts-ignore
    title: i18n.global.t('specimen.name'),
    field: 'name',
  },
  {
    title: '条形码',
    field: 'serial',
  },
  {
    // @ts-ignore
    title: i18n.global.t('specimen.original_serial'),
    field: 'originalSerial',
  },
  {
    title: '采样地点',
    field: 'sampleAddress',
  },
  {
    title: '状态',
    field: 'status',
    slots: {
      default: ({ row }) => (
        <div style={`color:${row.status === 1 ? 'green' : 'red'}`}>
          {row.status === 1 ? '正常' : '超时'}
        </div>
      ),
    },
  },
];
